﻿namespace TipGames
{
    internal class Program
    {
        /// <summary>
        /// 测试反应力小游戏
        /// </summary>
        /// <param name="args"></param>
        //操作次数
        const int N = 10;
        static void Main(string[] args)
        {
            //设置随机变量
            Random rand = new Random();
            //进行次数和错误次数
            int times = 1, wrongtimes = 0;
            char str, input;
            //开始时间
            DateTime begintime = DateTime.Now;
            while (times < N + 1)
            {
                Console.WriteLine($"正在进行第{times}次：");
                //65-90为"A"-"Z"，97-122为"a"-"z"
                do
                {
                    str = (char)rand.Next(65, 122);
                }
                while (str > 'Z' && str < 'a');
                Console.Write(str + "——");
                input = Console.ReadKey().KeyChar;
                Console.WriteLine();
                //判断输入是否正确
                if (input != str)
                {
                    do
                    {
                        wrongtimes++;
                        input = Console.ReadKey().KeyChar;
                        Console .WriteLine();
                    } while (input != str);
                }
                times++;

            }
            //结束时间
            DateTime endtime = DateTime.Now;
            //计算总耗时
            TimeSpan totaluse = endtime - begintime;
            Console.Write($"用时{totaluse.ToString()},错误{wrongtimes}次");
            Console.ReadKey();
        }
    }
}